<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no, viewport-fit=cover" />
        <link rel="icon" type="image/png" href="/favicon.png" />
        <meta name="renderer" content="webkit" />
        <meta name="force-rendering" content="webkit" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>登录中</title>
        <script src="/src/library/jquery/1.8.3/jquery.js"></script>
    </head>

    <body>
        <script>
            var __api_server__ = <%- apiServer %>;
            var getRequest = () => {
                var encodeUrl = new URL(location.href.replace('#', encodeURIComponent('#')));
                var search = encodeUrl.search.replace('?', '');
                var theRequest = new Object();
                var strs = search.split('&');
                for (var i = 0; i < strs.length; i++) {
                    var result = strs[i].split('=');
                    theRequest[result[0]] = decodeURIComponent(result[1]);
                }
                return theRequest;
            };
            var request = getRequest();

            $.ajax({
                    url: __api_server__.main + "ExternalPortal/ExportalSSO",
                    type: 'POST',
                    data: JSON.stringify(request),
                    dataType: 'JSON',
                    contentType: 'application/json',
                }).done(res => {
                    if (res.data.code === 0) {
                        location.href = '/portal/' + request.appId;
                    } else {
                        alert(res.data.message);
                    }
                }).fail(res => {
                    alert('服务异常，登录失败!');
                })
        </script>
    </body>
</html>
